﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Xunit;
using M3G;

namespace MyTestProject {

    public class TestBackground {
        [Fact]
        public void TestContstructor () {
            var bg = new Background ();
            Assert.Equal (0x00000000u, bg.Color);
            Assert.Equal (0xffffffffu, bg.ColorClearMask);
            Assert.Equal (1.0f, bg.Depth);
            Assert.Equal (true, bg.DepthClearEnabled);
            Assert.Equal (0, bg.Stencil);
            Assert.Equal (0xffffffffu, bg.StencilClearMask);
        }

        [Fact]
        public void TestGetColor () {
            var bg = new Background ();
            bg.SetColor (0x87654321);

            Assert.Equal (0x87654321u, bg.Color);
        }

        [Fact]
        public void TestGetColorClearMask () {
            var bg = new Background ();
            bg.SetColorClearMask (0xff00ff00);

            Assert.Equal (0xff00ff00u, bg.ColorClearMask);
        }

        [Fact]
        public void TestGetDepth () {
            var bg = new Background ();
            bg.SetDepth (-99.9f);

            Assert.Equal (0.0f, bg.Depth);
        }

        [Fact]
        public void TestDepthClearEnabled () {
            var bg = new Background ();
            bg.SetDepthClearEnable (false);

            Assert.Equal (false, bg.DepthClearEnabled);
        }

        [Fact]
        public void TestGetStencil () {
            var bg = new Background ();
            bg.SetStencil (0x12345678);

            Assert.Equal (0x12345678, bg.Stencil);
        }

        [Fact]
        public void TestGetStencilClearMask () {
            var bg = new Background ();
            bg.SetStencilClearMask (0x00ff00ff);

            Assert.Equal (0x00ff00ffu, bg.StencilClearMask);
        }

        [Fact]
        public void TestDuplicate () {
            var bg = new Background ();
            bg.SetStencilClearMask (0x00ff00ff);
            bg.SetColorClearMask (0xff00ff00);
            bg.SetColor (0x87654321);
            bg.SetDepth (-99.9f);
            bg.SetDepthClearEnable(false);
            bg.SetStencil (0x12345678);
            bg.SetStencilClearMask (0x00ff00ff);
            bg.UserID =100;

            var dup = (Background)bg.Duplicate ();

            Assert.Equal (bg.Color, dup.Color);
            Assert.Equal (bg.ColorClearMask, dup.ColorClearMask);
            Assert.Equal (bg.Depth, dup.Depth);
            Assert.Equal (bg.DepthClearEnabled, dup.DepthClearEnabled);
            Assert.Equal (bg.Stencil, dup.Stencil);
            Assert.Equal (bg.StencilClearMask, dup.StencilClearMask);
            Assert.Equal (bg.UserID, dup.UserID);
        }
    }
}
